﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ApisixSDK.Admin.model
{
    public class Health_Checker
    {
        [JsonProperty(propertyName: "active")]
        public ActiveCheck Active { get; set; }
        [JsonProperty(propertyName: "passive")]
        public PassiveCheck Passive { get; set; }
    }

    public class ActiveCheck
    {
        [JsonProperty(propertyName: "timeout")]
        public int Timeout { get; set; }
        [JsonProperty(propertyName: "http_path")]
        public string HttpPath { get; set; }
        [JsonProperty(propertyName: "host")]
        public string Host { get; set; }
        /// <summary>
        /// <code>["User-Agent: curl/7.29.0"]</code>
        /// </summary>
        [JsonProperty(propertyName: "req_headers")]
        public IList<string> ReqHeaders { get; set; }

        [JsonProperty(propertyName: "healthy")]
        public HealthyModel Healthy { get; set; }

        [JsonProperty(propertyName: "unhealthy")]
        public UnHealthyModel UnHealthy { get; set; }

        public class HealthyModel
        {
            [JsonProperty(propertyName: "interval")]
            public int? Interval { get; set; }
            [JsonProperty(propertyName: "successes")]
            public int? Successes { get; set; }
        }

        public class UnHealthyModel
        {
            [JsonProperty(propertyName: "interval")]
            public int? Interval { get; set; }
            [JsonProperty(propertyName: "http_failures")]
            public int? HttpFailures { get; set; }
        }
    }
    public class PassiveCheck
    {
        [JsonProperty(propertyName: "healthy")]
        public HealthyModel Healthy { get; set; }
        [JsonProperty(propertyName: "unhealthy")]
        public UnHealthyModel UnHealthy { get; set; }

        public class HealthyModel
        {
            [JsonProperty(propertyName: "http_statuses")]
            public IList<int> HttpStatuses { get; set; }
            [JsonProperty(propertyName: "successes")]
            public int? Successes { get; set; }
        }
       
        public class UnHealthyModel
        {
            [JsonProperty(propertyName: "http_statuses")]
            public IList<int> HttpStatuses { get; set; }
            [JsonProperty(propertyName: "http_failures")]
            public int? HttpFailures { get; set; }
            [JsonProperty(propertyName: "tcp_failures")]
            public int? TcpFailures { get; set; }
        }
    }
}
